package com.qf.test2;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Test2 {
	
	public static void main(String[] args) {
		
		Integer arrlist[]= {2,3,8,7,1,5};
		
		
		int max=arrlist[arrlist.length-1],min=arrlist[0],tmp,maxFlag=0,minFlag=0;
		//最大值交换
		for (int i = 0; i < arrlist.length-1; i++) {
			if(max<arrlist[i]) {
				max=arrlist[i];
				
				
			}
		}
		//最小值交换
		for (int i = 1; i < arrlist.length; i++) {
			if(min>arrlist[i]) {
				min=arrlist[i];
				
			}
		}
		for (int i = 0; i < arrlist.length; i++) {
			if(max==arrlist[i]) {
				maxFlag = i;
			}
			if(min==arrlist[i]) {
				minFlag = i;
			}
		}
		
		tmp = arrlist[maxFlag]; 
		arrlist[maxFlag] = arrlist[arrlist.length-1];
		arrlist[arrlist.length-1] = tmp;
		
		tmp = arrlist[minFlag]; 
		arrlist[minFlag] = arrlist[0];
		arrlist[0] = tmp;
		
		System.out.println(max+""+min);
		System.out.println(maxFlag+""+minFlag);
		for (int i = 0; i < arrlist.length; i++) {
			System.out.print(arrlist[i]+" ");
		}
		
	}

}
